(deftemplate ruta (slot plecare) (slot sosire) (slot distanta))

(deffacts myFacts
    (ruta (plecare "Toronto") (sosire "Vancouver") (distanta 3366))
    (ruta (plecare "Toronto") (sosire "Los Angeles") (distanta 3513))
    (ruta (plecare "Toronto") (sosire "Chicago") (distanta 701))
    (ruta (plecare "New York") (sosire "Toronto") (distanta 554))
    (ruta (plecare "New York") (sosire "Chicago") (distanta 1149))
    (ruta (plecare "New York") (sosire "Denver") (distanta 2616))
    (ruta (plecare "Chicago") (sosire "Denver") (distanta 1479))
    (ruta (plecare "Denver") (sosire "Memphis") (distanta 1410))
    (ruta (plecare "Denver") (sosire "Houston") (distanta 1413))
    (ruta (plecare "Denver") (sosire "Los Angeles") (distanta 1338))
    (ruta (plecare "Houston") (sosire "Los Angeles") (distanta 2205))
)

(reset)
(defrule ruteNewYork
    (ruta (plecare "New York") (sosire ?s) (distanta ?d))
    =>
    (printout t "- sosire in " ?s ", cu distanta de " ?d " km." crlf)
)
(printout t "Toate zborurile care pleaca din New York:" crlf)
(run)
(defrule distante
    (ruta {distanta > 800 && distanta < 2200} (plecare ?p) (sosire ?s) (distanta ?d))
    =>
    (printout t "Plecare din " ?p ", sosire in " ?s ", cu distanta de " ?d " km." crlf)
)
(printout t crlf "Zborurile cu distanta cuprinsa intre 800 km si 2200 km sunt urmatoarele: " crlf)
(run)